home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
qlib205.zip
/
QLIB.ZIP
/
C
/
DO.H
< prev
next >
Wrap
Text File
|
1997-04-27
|
1KB
|
60 lines
// recursive func!
void dofile(void) {
word incoff;
word p;
//open file
//send to other routine
//close file
ch++;
//below is almost impossible (mh=64)
if (ch==mh) error("LIMIT:Too many include files(64) (increase mh in sources)\r\n");
h=open(file,O_BINARY|O_RDONLY);
strcpy(buffn[ch],file);
if (h==-1) {
if (inc!=NULL) {
incoff=0;
while (h==-1) {
if (!(*(inc+incoff))) break;
p=0;
while (*(inc+incoff)) {
t2[p++]=*(inc+incoff++);
if ((*(inc+incoff))==';') {incoff++;break;}
}
t2[p]=0;
strcat(t2,"\\");
strcat(t2,file);
h=open(t2,O_BINARY|O_RDONLY);
}
}
if (h==-1) {
sprintf(str,"Can't open file : %s\r\n",file);
error(str);
}
}
#ifdef DEBUG
printf(" %s opened\n",file);
#endif
hs[ch]=h;
bufin[ch]=(byte *)malloc(bufsiz);
if ( ((dword) bufin[ch]) == ERROR ) error("Out of memory\n");
bufip[ch]=0;
bufis[ch]=0; //size left
bufln[ch]=0; //line #
EOFF[ch]=0;
prefile(); //pre process the file!
free(bufin[ch]);
close(h);
#ifdef DEBUG
printf(" closed\n");
#endif
ch--;
if (ch!=255) {
h=hs[ch];
if (!h) {
printf("Unknown error:h=0 ch=%d! \r\n",ch);
exit(0);
}
}
}